#ifndef __HMAC_CLASS__
#define __HMAC_CLASS__

#include "MessageDigest.h"
#include <cstdint>
#include <string>

class HMAC {
private:
	uint8_t mKey[64];
	MessageDigest *mAlgorithm;
	HMAC(const HMAC &hmac){}
	HMAC& operator=(const HMAC &hmac){}

public:
	explicit HMAC(int type){mAlgorithm = new MessageDigest(type);}
	~HMAC() {
		if (mAlgorithm) delete mAlgorithm;
		mAlgorithm = NULL;
	}
	int getType(){return mAlgorithm->getType();}
	unsigned int getSize(){return mAlgorithm->getSize();}
	void init(const void *key, unsigned int size);
	void update(const void *data, unsigned int size);
	void final();
	const unsigned char *getDigest(){return mAlgorithm->getDigest();}
	void digestHex(char *hex){MessageDigest::digestHex(hex, getDigest(), getSize());}
	const std::string getDigestHex(){return MessageDigest::digestHex(getDigest(), getSize());}
};

#endif